<template>
  <el-upload
    ref="eluploadfile"
    :action="FileUrl"
    :multiple="isMultiple"
    :show-file-list="false"
    :data="Data"
    :auto-upload="isAutoUpload"
    :headers="httpHeaders"
    :before-upload="beforeAvatarUpload"
    :on-success="handleAvatarSuccess"
    :on-preview="handlePreviewFile"
  >
    <el-button size="small" type="primary">点击上传</el-button>
    <div class="el-upload__tip" slot="tip">
      <p>只能上传文件格式为{{fileType}}</p>
    </div>
  </el-upload>
</template>

<script>
import { getToken } from "@/utils/auth";
export default {
  name: "FileUpload",
  props: {
    fileType:{
     type: String,
     default: 'PDF'
    },
    Data: {
      type: Object
    },
    FileUrl: {
      type: String
    },
    handleAvatarSuccess: {
      type: Function
    },
    isMultiple: {
      type: Boolean,
      default: true
    },
    isAutoUpload:{
       type:Boolean,
       default:false
    },
    beforeAvatarUpload:{
      type: Function
    }
  },
  data() {
    return {
      httpHeaders: {
        Authorization: getToken()
      }
    };
  },
  methods: {
    
    handlePreviewFile(file) {
    },
    // 上传文件
    UploadSubmit() {
      this.$refs.eluploadfile.submit();
    },
    // 清除文件
    clearFiles() {
      this.$refs.eluploadfile.clearFiles();
    }
  }
};
</script>


